package csdn;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 项目名称：wangxu
 * 类 名 称：RealTopic01
 * 描 述：https://dream.blog.csdn.net/article/details/129548578
 * 创建时间：2023/4/5 7:05 下午
 * 创 建 人：wang-xu
 */
public class RealTopic01 {
    public static void main(String[] args) {
        try {
//            Scanner in = new Scanner(System.in);
//            String input = in.nextLine();
            String input="asfefaweawfaw(10,1)fe(199,21)\n";
            if (input.isEmpty()){
                System.out.println("input is null");
            }
            solve(input);
        }catch (Exception e){
            System.out.println("input error");
            e.printStackTrace();
        }
    }

    public static void solve(String input) {
        int left = 0;
        int right = 0;
        List<Integer> myList = new ArrayList<>();
        List<List<Integer>> allList = new ArrayList<>();

        for (int i = 0; i < input.length(); i++) {
            if (input.charAt(i) == '('){
                left = i+1;
            }
            if (input.charAt(i) == ')'){
                right = i;
            }
            if (right!=0){
                String[] value = input.substring(left, right).split(",");
                int a = Integer.parseInt(value[0]);
                int b = Integer.parseInt(value[1]);
                if (value[0].charAt(0) !='0' && value[1].charAt(0) !='0' && a > 0 && a <1000 && b > 0 && b < 1000){
                    myList.add(a);
                    myList.add(b);
                    allList.add(myList);
                    myList = new ArrayList<>();
                }
                left = 0;
                right = 0;
            }
        }
        if (!allList.isEmpty()){
            // 求平方和
            allList.sort((i,j)->{
                int ax = i.get(0)*i.get(0)+i.get(1)*i.get(1);
                int bx = j.get(0)*j.get(0)+j.get(1)*j.get(1);
                if (bx >=ax){
                    return 1;
                }
                return -1;
            });
            System.out.println("("+allList.get(0).get(0)+","+allList.get(0).get(1)+")");
        }else {
            System.out.println("(0,0)");
        }
    }
}
